package cn.boy.web.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.InvocationTargetException;
import java.util.Date;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.sun.org.apache.commons.beanutils.BeanUtils;

import cn.boy.domain.Dormitory;
import cn.boy.service.DormitoryService;
import cn.boy.service.DormitoryServiceFactory;

public class UpdateDormitoryMark extends HttpServlet {

	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		
		String no = request.getParameter("no");
		String name = request.getParameter("name");
		String mark = request.getParameter("mark");
		long time = System.currentTimeMillis();
		Date date = new Date(time);
		Dormitory dorm = new Dormitory(no, name, mark, date.toLocaleString());
		
		DormitoryServiceFactory instance = DormitoryServiceFactory.getInstance();
		DormitoryService service = instance.getDormitoryService();
		service.addDormitory(dorm);

	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doGet(request, response);
	}

}
